import { Component, OnInit } from '@angular/core';
import {TimeUtils} from 'great-jsutils';

@Component({
  selector: 'app-time-test',
  templateUrl: './time-test.component.html',
  styleUrls: ['./time-test.component.less']
})
export class TimeTestComponent implements OnInit {

  hello = TimeUtils.sayHello();
  fourDaysAgo = TimeUtils.getDayTime(-4);
  threeDaysAgo = TimeUtils.getDayTime(-3);
  beforeYesterday = TimeUtils.getDayTime(-2);
  yesterday = TimeUtils.getDayTime(-1);
  today = TimeUtils.getDayTime();
  tomorrow = TimeUtils.getDayTime(1);
  afterTomorrow = TimeUtils.getDayTime(2);
  within30days = {};
  within7days = {};

  previousWeek = TimeUtils.getWeekTime(-2);
  lastWeek = TimeUtils.getWeekTime(-1);
  thisWeek = TimeUtils.getWeekTime();
  nextWeek = TimeUtils.getWeekTime(1);
  lastMonth = TimeUtils.getMonthTime(-1);
  thisMonth = TimeUtils.getMonthTime();
  nextMonth = TimeUtils.getMonthTime(1);
  lastQuarter = TimeUtils.getQuarterTime(-1);
  thisQuarter = TimeUtils.getQuarterTime();
  nextQuarter = TimeUtils.getQuarterTime(1);
  lastYear = TimeUtils.getYearTime(-1);
  thisYear = TimeUtils.getYearTime();
  nextYear = TimeUtils.getYearTime(1);
  randomTimeList = [];

  constructor() {
    const start2 = TimeUtils.getDayTime(-6).start;
    const start = TimeUtils.getDayTime(-29).start;
    const end = TimeUtils.getDayTime().end;
    this.within30days = {start, end};
    this.within7days = {start2, end};
  }

  ngOnInit() {
    for (let i = 0; i < 5; i++) {
      this.randomTimeList.push({
        'time1': TimeUtils.random(),
        'time2': TimeUtils.format(TimeUtils.random()),
        'time3': TimeUtils.format(new Date(), TimeUtils.FORMAT_FULL_CN),
        'time4': TimeUtils.format(TimeUtils.random(), 'yyyy-MM-dd'),
        'time5': TimeUtils.format()
      });
    }
  }

}
